
var StringTranslate={
	'use':1,
	'langName':[
		'en-US',
		'zh-CN'
	],
	'uiClass':{}
}
StringTranslate.text=function(textStr,uiClassName){
	if(textStr==='' || textStr===undefined){
		return textStr;
	}
	var tranStr,tranResultStr,tranLangList,uiClassTranslateData;
	uiClassTranslateData=StringTranslate.uiClass[uiClassName];
	if(uiClassTranslateData!==undefined){
		tranLangList=uiClassTranslateData[textStr];
		if(tranLangList!==undefined){
			tranResultStr=tranLangList[StringTranslate.use];
			if(tranResultStr!==undefined){
				return tranResultStr;
			}
		}
	}
	return textStr;
}
StringTranslate.$dom=function($boxDom){
	function domTranslate($dom){
		var textStr;
		var uiClassName=$dom.attr('data-translate')
		function inputTranslate(){
			var $input=$dom;
			var tranStr='';
			var dataTipsStr=$input.attr('data-tips');
			var valueStr=$input.val();
			if(dataTipsStr!==undefined){
				tranStr=StringTranslate.text(dataTipsStr,uiClassName);
				$input.attr('data-tips',tranStr);
				if(dataTipsStr===valueStr){
					$input.val(tranStr);
				}
			}else{
				tranStr=StringTranslate.text(valueStr,uiClassName);
				$input.val(tranStr);
			}
		}
		function defaultTranslate(){
			var htmlStr=$dom.html();
			var tranStr=StringTranslate.text(htmlStr,uiClassName);
			$dom.html(tranStr);
		}
		function titleTranslate(){
			var titleStr=$dom.attr('title');
			var tranStr='';
			if(titleStr!==undefined){
				tranStr=StringTranslate.text(titleStr,uiClassName);
				$dom.attr('title',tranStr);
			}
		}
		switch ($dom[0].tagName.toLowerCase()){
			case 'input':
				inputTranslate();
				break;
			default:
				defaultTranslate();
				break;
		}
		titleTranslate();
		$dom.removeAttr('data-translate')
	}
	if($boxDom===undefined){
		$boxDom=$('body');
	}
	$boxDom.find('[data-translate]').each(function(){
		domTranslate($(this));
	})
	$boxDom.find('.style-translate').each(function(){
		$(this).addClass('style-'+StringTranslate.langName[StringTranslate.use]).removeClass('style-translate')
	})
}

String.prototype.tr=function(uiClassName){
	return StringTranslate.text(this,uiClassName);
};